#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 3e5 + 10;

int n;
int f[N], a[N];

void solve(){
    cin >> n;
    int maxv = 0;
    for(int i = 0; i < n; i ++) cin >> a[i];

    for(int i = 0; i < n; i ++){
        f[i] = 1;
        for(int j = max(i - 256, 0); j < i; j ++){
            if((a[j] ^ i) < (a[i] ^ j)){
                f[i] = max(f[i], f[j] + 1);
            }
        }
        maxv = max(maxv, f[i]);
    }

    cout << maxv << '\n';
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while(T--){
        solve();
    }


    return 0;
}